package xyz.ag;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;

import xyz.ag.Beans.Book;
import xyz.ag.Beans.Shoppingcart;
import xyz.ag.Beans.User;
import xyz.ag.DAO.impl.BookDAOInterfaceImpl;
import xyz.ag.DAO.impl.CartAndOrderDAOInterfaceImpl;
import xyz.ag.Service.impl.BookServiceInterfaceImpl;
import xyz.ag.Service.impl.CartAndOrderServiceInterfaceImpl;

/**
 * 测试类
 * @author User
 *
 */
public class test {
	public static void main(String[] args) throws Exception {
//		String method0  = "/233.douser";//获取路径
//		String method = "";
//		try {
//			 method = method0.substring(8,method0.length()-7);
//		} catch (Exception  a) {
//			 method = method0.substring(1,method0.length()-7);
//		}
//		System.out.println(method);
		
//		User user = new User.Builder().userName("123").build();
//		System.out.println(user.getUserName());
		
		function7();
	}

	private static void function8() throws SQLException {
		String bao = new BookDAOInterfaceImpl().getBookcategoryByID("1");
		System.out.println(bao);
		
	}

	private static void function7() {
		Book book = new BookServiceInterfaceImpl().shouBookByBookName("java基础");
		String s = JSON.toJSONString(book).toString();
		System.out.println(s);
	}

	private static void function6() {
		System.out.println( new BookDAOInterfaceImpl().getbookificationIDByCondlition("计算机-java"));
		
	}

	private static void function5() throws Exception {
		ArrayList<Book> bookListByCondition = new BookDAOInterfaceImpl().getBookListByCondition("0","8","ALL");
		for (Book book : bookListByCondition) {
			System.out.println(book.getBookName());
		}
		
	}

	private static void function4() {
		User user = new User();
		user.setUserName("admin");
		user.setUserPassword("admin");
		ArrayList<Shoppingcart> shoppingcarLimitpageList = new CartAndOrderServiceInterfaceImpl().getShoppingcarLimitpageList("1","10",user);
		//String i =new CartAndOrderServiceInterfaceImpl().getshpooingcarListNmuber(user);
		
		System.out.println(JSON.toJSON(shoppingcarLimitpageList).toString());
	}

	private static void function3() {
		CartAndOrderDAOInterfaceImpl  ca = new CartAndOrderDAOInterfaceImpl();
		
	}

	private static void function2() {
	  String s = "计算机-java";
	  System.out.println(s.split("-")[1]);
	}

	private static void function1() {
		List<Book> list = new ArrayList<Book>();
		Book book1 = new Book("图书名","作者","出版社","路径");
		Book book2 = new Book("图书名2","作者2","出版社2","路径2");
		list.add(book1);
		list.add(book2);
	    System.out.println(JSON.toJSON(list).toString());
		
	}
}
